#ifndef LOGINWINDOW_H
#define LOGINWINDOW_H
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QMessageBox>

#include "registerwindow.h"
#include <memory>

namespace Ui {
class LoginWindow;
}

class LoginWindow : public QWidget
{
    Q_OBJECT

public:
    explicit LoginWindow(QWidget *parent = nullptr);
    ~LoginWindow();

protected:
    void showEvent(QShowEvent *event) override;

    void openMainWindow();

public slots:
    void recvDbStatus(const QByteArray& status, const quint16& userId, const QByteArray& username, const quint16& userType);

private slots:
    void on_pushButton_login_clicked();
    void on_pushButton_register_clicked();

private:
    Ui::LoginWindow *ui;
    DbHandler* dbHandler;
    std::unique_ptr<RegisterWindow> registerWindow;
    
    void showStatus(const QString &message, bool isError = true);
    void clearStatus();
    bool validateInput();
};

#endif // LOGINWINDOW_H
